The code below is designed so that my local machine will kill a specific process remotely via powershell...Well i just renamed ALL the machines on my domain and would like to optimize all the scripts i have created. I would like to have the code for each machine as follows:
- start powershell{ $remote = new-pssession -computername CPU-180 import-pssession -session $remote -commandname *-process -prefix remote get-remoteprocess -name fwt | stop-remoteprocess -force;}
However that method, the code does not execute correctly. It does not throw an error but it doesnt do what it is supposed to do. This way it will work just fine:
- start powershell{ $remote = new-pssession -computername CPU-180
- import-pssession -session $remote -commandname *-process -prefix remote
- get-remoteprocess -name fwt | stop-remoteprocess -force;}
Now, is there a command or some sort of trigger that i can use to signify in the source code a new line so i dont have such a long script ?
PS: Im working on creating a script that employs a while loop but for now i need this figured out.